package com.yunmai.library.util;

import android.content.Context;
import android.widget.Toast;

/**
 * @author True Lies
 * <p>
 * 不重复显示的Toast
 * <p>
 * Created by Coding on 2018/3/15.
 */

public class CustomToast {

  private static Toast mToast;
  private static Runnable r = new Runnable() {
    public void run() {
      mToast.cancel();
    }
  };

  /**
   * 弹出框
   */
  public static void showToast(String text, Context context) {
    //UiInstance.getInstance().getHandler().removeCallbacks(r);
    if (mToast != null) {
      mToast.setText(text);
    } else {
      mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    }
    mToast.show();
  }

  /**
   * 弹出框 文字
   */
  public static void showToast(int resId, Context context) {
    showToast(context.getResources().getString(resId), context);
  }
}
